import os
from typing import Optional

from pydantic import BaseModel


class BailianSettings(BaseModel):
    api_key: Optional[str] = os.environ.get("BAILIAN_API_KEY")
    base_url: str = os.environ.get(
        "BAILIAN_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1"
    )
    model: str = os.environ.get("BAILIAN_MODEL", "qwen-max")


class AlibabaCloudSettings(BaseModel):
    access_key_id: Optional[str] = os.environ.get("ALIBABA_CLOUD_ACCESS_KEY_ID")
    access_key_secret: Optional[str] = os.environ.get(
        "ALIBABA_CLOUD_ACCESS_KEY_SECRET"
    )


class ExternalServicesSettings(BaseModel):
    amap_key: Optional[str] = os.environ.get("AMAP_KEY")


class Settings(BaseModel):
    bailian: BailianSettings = BailianSettings()
    alibaba_cloud: AlibabaCloudSettings = AlibabaCloudSettings()
    external: ExternalServicesSettings = ExternalServicesSettings()


settings = Settings()


